package framework.detectors;

import framework.IWildPointDetector;

/**
 *
 * Implementation of Detector interface to identify values that fall outside a a given value range
 */
public class OutOfRangeDetector implements IWildPointDetector {
	
	private double minimum;
	private double maximum;

	/**
         *
         * @param minimum The lower value of the range against which the value will be compared
         * @param maximum The upper value of the range against which the value will be compared
         */
	public OutOfRangeDetector(double minimum,double maximum)
	{
		this.minimum = minimum;
		this.maximum = maximum;
	}

        /**
         *
         * @param measures Array of measurements to be analyzed. However, only the first element is considered.
         * @return True if the first element of the array is out of the range defined
         *
         */
	public boolean detect(long[] measures) {
        return this.maximum < Double.longBitsToDouble(measures[0])
                || this.minimum > Double.longBitsToDouble(measures[0]);
    }

}
